﻿@model ZDSoft.UPMS.Model.BusinessPart.Situation
@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
<html>
<head>
    <title>平时成绩管理系统</title>
    <link href='@Url.Content("~/Content/css/Common.css")' rel="stylesheet" type="text/css" />
    <script src='@Url.Content("~/Scripts/jquery-1.5.1.min.js")' type="text/javascript"></script>
    <link href='@Url.Content("~/Content/tab/css/ui-lightness/jquery-ui-1.7.1.custom.css")' rel="stylesheet"
        type="text/css" />
    <link href='@Url.Content("~/Scripts/PageCreater/Css/Style.css")' rel="stylesheet" type="text/css" />
    <link href='@Url.Content("~/Content/tab/css/style.css")' rel="stylesheet" type="text/css" />
    <script src='@Url.Content("~/Scripts/jquery.simplemodal.1.4.1.min.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/calendar/WdatePicker.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/jquery.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/ui.core.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/ui.tabs.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/ui.ariaTabs.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Scripts/jquery.simplemodal.1.4.1.min.js")' type="text/javascript"></script>
    <link href='@Url.Content("~/Content/css/SimpleDialog.css")' rel="stylesheet" type="text/css" />
     <script type="text/javascript">
        var aNum;
        var situationTypeID = 0;
        $(document).ready(function () {
            var tabsTitle = $("#tabs").tabs();
            $.ajax({
                type: "post",
                url: "/Situation/FindTypeFirstID", data: {},
                success: function (data) {
                    situationTypeID = data;
                }
            });
        });

        function SwithSelectedSituation(i) {
            situationTypeID = i;
        }
        function SubmitPage() {
            if ($("#inputTime").val() == "") {
                alert("请选择录入日期！");
                return false;
            }

            var selectMsgs = "", txtRemark = "", txtUserNumber = "", txtTypeID = "";
            $(":select[name='msg-" + situationTypeID + "']").each(function () {
                selectMsgs += ($(this).val()).toString() + ",";
            });

            $(":input[name='remark-" + situationTypeID + "']").each(function () {
                txtRemark += ($(this).val()).toString() + ",";
            });
            $(":input[name='txtUserNumber-" + situationTypeID + "']").each(function () {
                txtUserNumber += ($(this).val()).toString() + ",";

            });
            $(":input[name='txtTypeID-" + situationTypeID + "']").each(function () {
                txtTypeID += ($(this).val()).toString() + ",";

            });
            var actionName = "Create";
            $.ajax({
                type: "post",
                url: "/Situation/SituationCreate",
                data: { ddlOrganization: $("#ddlOrganization").val(), ddlCourse: $("#ddlCourse").val(), inputTime: $("#inputTime").val(), selectMsg: selectMsgs, txtTypeID: txtTypeID, txtUserNumber: txtUserNumber, txtRemark: txtRemark },
                success: function (data) {
                    alert("添加成功!");
                },
                beforeSend: function () { $.modal("<img src='../../Content/images/loading.gif' alt=''/>"); },
                complete: function () { $.modal.close(); }
            });
        }
    </script>
</head>
<body>
    @{
        IList<ZDSoft.UPMS.Model.BusinessPart.SituationType> list = TempData["ParentsType"] as IList<ZDSoft.UPMS.Model.BusinessPart.SituationType>;
        IList<ZDSoft.UPMS.Model.SystemPart.User> stuList = TempData["Student"] as IList<ZDSoft.UPMS.Model.SystemPart.User>;
    }
    <div>
        @if (stuList == null || stuList.Count() == 0)
        {
            <span style="color:Red; font-size:larger;">对不起，本学期您没有教课,不能进行该项操作</span> 
        }
        else
        {
            <div>
                班级：@Html.DropDownList("ddlOrganization", new SelectList(ViewBag.Organization, "ID", "Name"))
                &nbsp;&nbsp; 课程：@Html.DropDownList("ddlCourse", new SelectList(ViewBag.Course, "ID", "Name"))
                &nbsp;&nbsp; 时间：<input class="Wdate" id="inputTime" name="inputTime" type="text" value="@(DateTime.Now.ToShortDateString())"
                onfocus=" WdatePicker({ dateFmt: 'yyyy/MM/dd', minDate: '2012/01/01', maxDate: 'DateTime.Now'})" /></div>
            <div style="color:Red; font-size:larger; padding-top:5px;">注意：作业情况为未完成作业次数，纪律情况为违反纪律次数，课堂表现为应受表扬次数</div>
            <div id="tabs">
                <input type="text" id="selectMsg" name="selectMsg" style="visibility: hidden;" />
                <ul>
                    @for (var pr = 0; pr < list.Count; pr++)
                    {
                        <li><a href="#tabs-@pr" onclick="SwithSelectedSituation(@list[pr].ID)">@list[pr].Name</a></li>
                    }
                </ul>
                @for (var g = 0; g < list.Count; g++)
                {
                    <div id="tabs-@g">
                        <table border="1" cellspacing="0" cellpadding="0">
                            <tr>
                                <th>
                                    学号
                                </th>
                                <th>
                                    姓名
                                </th>
                                @for (var i = 0; i < list[g].Children.Count; i++)
                                {<th>
                                    <input type="text" id="txtTypeID" name="txtTypeID-@list[g].ID" value="@(list[g].Children[i].ID)" class="v"/>@(list[g].Children[i].Name)
                                </th>}<th>
                                    备注
                                </th>
                            </tr>
                            @foreach (var item in stuList)
                            {<tr>
                                <td>@Html.DisplayFor(model => item.UserNumber)
                                    <input type="text" id="txtUserNumber" name="txtUserNumber-@list[g].ID" value="@item.ID" class="v" />
                                </td>
                                <td>@Html.DisplayFor(model => item.Name)
                                </td>
                                @for (var i = 0; i < list[g].Children.Count; i++)
                                {<td>
                                    <select size="1" name="msg-@list[g].ID" style=" width:37px;">
                                        @for (var j = 0; j <= 10; j++)
                                        {<option value="@j">@j</option>}
                                    </select>
                                </td>}<td>
                                    <input type="text" id="remark" name="remark-@list[g].ID" />
                                </td>
                            </tr>}
                        </table>
                        <p>
                            <input type="text" id="stuNum" name="stuNum" value="@stuList.Count" class="v" />
                            <input type="button" onclick=" return SubmitPage()" value="保存" class="btn3" /></p>
                    </div>
               
                }
            </div>   
        }
    </div>
</body>
</html>
